package com.lgx.mall.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lgx.common.exception.DataException;
import com.lgx.common.web.Pagination;
import com.lgx.mall.core.dao.IBrandDao;
import com.lgx.mall.core.entity.Brand;
import com.lgx.mall.core.service.IBrandService;
/**
 * 
 * @author yry
 *
 */
@Service("brandService")
public class BrandService implements IBrandService {
	
	@Autowired
	private IBrandDao brandDao;

	public void setBrandDao(IBrandDao brandDao) {
		this.brandDao = brandDao;
	}

	public Brand createBrand(Brand brand) throws DataException {
		
		return this.brandDao.createBrand(brand);
	}

	
	public Brand updateBrand(Brand brand) throws DataException {
		
		return this.brandDao.updateBrand(brand);
	}

	
	public void deleteBrand(Brand brand) throws DataException {
		this.brandDao.deleteBrand(brand);
	}

	
	public void deleteBrand(long id) throws DataException {
		this.brandDao.deleteBrand(id);
	}

	
	public Brand findBrandById(long id) {
		return this.brandDao.findBrandById(id);
	}

	public List<Brand> findBrandList(String sql) {	
		return this.brandDao.findBrandList(sql);
	}
	
	public List<Brand> findBrandList(){
		return this.brandDao.findBrandList();
	}
	
	public List<Brand> findBrandList(String sql, Object[] params, int pageSize,
			int pageNum) {
		return this.brandDao.findBrandList(sql, params, pageSize, pageNum);
	}

	
	public Pagination findBrandPagination(String sql, Object[] params,
			int pageSize, int pageNum) {
		return this.brandDao.findBrandPagination(sql, params, pageSize, pageNum);
	}

	
	public Pagination findBrandPagination(Object[] params, int pageSize,
			int pageNum) {
		return this.brandDao.findBrandPagination(params, pageSize, pageNum);
	}

	
	public void deleteBrands(String[] ids) {
		
		try {
			this.brandDao.deleteBrands(ids);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	public List<Brand> findBrandByName(String name) {
		return this.brandDao.findBrandByName(name);
	}

}
